import { type GeneralSetting, newGeneralSetting } from '@/api/types/Setting.ts'
import type { PersistencePluginOption } from '@/config/store/PersistencePlugin.ts'
import { defineStore } from 'pinia'
import { computed, ref } from 'vue'


export const useGeneralSettingStore = defineStore(
        '通用设置',
        () => {
            const setting = ref(newGeneralSetting())

            const enableDrag = computed(() => setting.value.enableDrag)
            const showCreateBtn = computed(() => setting.value.showCreateBtn)

            return {
                setting,
                enableDrag,
                showCreateBtn,
                setValue: (v: GeneralSetting) => setting.value = v,
            }
        },
        {
            persistencePlugin: {
                persistence: true,
                eternal: true,
            } as PersistencePluginOption,
        },
)
